/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.eps.modelo.javabeans;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author luis
 */
@Entity
@Table(name = "T_Rol")
@NamedQueries({
    @NamedQuery(name = "Rol.findAll", query = "SELECT r FROM Rol r"),
    @NamedQuery(name = "Rol.findByDescripcion", query = "SELECT r FROM Rol r WHERE r.descripcion = :descripcion"),
    @NamedQuery(name = "Rol.findByTRolID", query = "SELECT r FROM Rol r WHERE r.tRolID = :tRolID")})
public class Rol implements Serializable {
    private static final long serialVersionUID = 1L;
    @Basic(optional = false)
    @Column(name = "descripcion")
    private String descripcion;
    @Id
    @Basic(optional = false)
    @Column(name = "T_Rol_ID")
    private Integer tRolID;
    @JoinTable(name = "T_DetalleUsuarioRol", joinColumns = {
        @JoinColumn(name = "T_Rol_ID", referencedColumnName = "T_Rol_ID")}, inverseJoinColumns = {
        @JoinColumn(name = "T_Usuario_ID", referencedColumnName = "T_Usuario_ID")})
    @ManyToMany
    private List<Usuario> usuarioList;

    public Rol() {
    }

    public Rol(Integer tRolID) {
        this.tRolID = tRolID;
    }

    public Rol(Integer tRolID, String descripcion) {
        this.tRolID = tRolID;
        this.descripcion = descripcion;
    }

    public String getDescripcion() {
        return descripcion;
    }

    public void setDescripcion(String descripcion) {
        this.descripcion = descripcion;
    }

    public Integer getTRolID() {
        return tRolID;
    }

    public void setTRolID(Integer tRolID) {
        this.tRolID = tRolID;
    }

    public List<Usuario> getUsuarioList() {
        return usuarioList;
    }

    public void setUsuarioList(List<Usuario> usuarioList) {
        this.usuarioList = usuarioList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (tRolID != null ? tRolID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Rol)) {
            return false;
        }
        Rol other = (Rol) object;
        if ((this.tRolID == null && other.tRolID != null) || (this.tRolID != null && !this.tRolID.equals(other.tRolID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "murguia.ejb30.entity.COMER.Rol[tRolID=" + tRolID + "]";
    }

}
